package com.charging.serviceImpl;

import com.charging.bean.UserInfo;
import com.charging.mapper.UserInfoMapper;
import com.charging.service.UserInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 后台用户表 服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-12
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {


    /**
     * @param account
     * @param password
     * @param session
     * @return 登陆
     */
    @Override
    public boolean login(String account, String password, HttpSession session) {
        Map map = new HashMap<>();
        map.put("account",account);
        map.put("password",password);
        List<UserInfo> list = baseMapper.login(map);
        if (list.size()>0){
            session.setAttribute("userInfo",list.get(0));
            return true;
        }
        return false;
    }


}
